package it.fuesi.expired.adapters.mongo;

import org.bson.BSONObject;
import org.bson.BasicBSONObject;

import it.fuesi.expired.adapters.base.IAdapterQuery;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

public class MongoAdapterQuery implements IAdapterQuery<DBObject> {

	private DBObject query = new BasicDBObject();
	
	private MongoAdapterQuery(){
		super();
	}
	
	public static final MongoAdapterQuery build(){
		return new MongoAdapterQuery();
	}
	
	public static final MongoAdapterQuery build(String name, Object value){
		return build().append(name, value);
	}
	
	public static final MongoAdapterQuery build(String name, MongoAdapterQuery value){
		return build().append(name, value.getQuery());
	}
	
	@Override
	public MongoAdapterQuery append(String name, Object value) {
		query.put(name, value);
		return this;
	}
	
	@Override
	public MongoAdapterQuery appendSubQuery(String name, DBObject value) {
		query.put(name, value);
		return this;
	}
	
	@Override
	public DBObject getQuery() {
		return query;
	}


}
